//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "GarmanKohlagenProcess.h"
using namespace Cephei::QL::Processes;
#include <gen/QL/Quote.h>
#include <gen/QL/Termstructures/YieldTermStructure.h>
#include <gen/QL/Termstructures/Volatility/Equityfx/BlackVolTermStructure.h>
#include <gen/QL/Termstructures/Volatility/Equityfx/LocalVolTermStructure.h>
#include <gen/QL/Math/Array.h>
#include <gen/QL/Processes/GeneralizedBlackScholesProcess.h>
using namespace Cephei::QL;
using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Termstructures::Volatility::Equityfx;
using namespace Cephei::QL::Math;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (boost::shared_ptr<QuantLib::GarmanKohlagenProcess>& childNative, Object^ owner) : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
#ifdef HANDLE
	_phGarmanKohlagenProcess = NULL;
#endif
	_ppGarmanKohlagenProcess = &childNative;
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppGarmanKohlagenProcess));
}
Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (QuantLib::GarmanKohlagenProcess& childNative, Object^ owner) : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
#ifdef HANDLE
	_phGarmanKohlagenProcess = NULL;
#endif
	_ppGarmanKohlagenProcess = new boost::shared_ptr<QuantLib::GarmanKohlagenProcess> (&childNative);
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppGarmanKohlagenProcess));
    _GarmanKohlagenProcessOwner = owner;
    _GeneralizedBlackScholesProcessOwner = owner;
}

Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (CGarmanKohlagenProcess^ copy) : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
#ifdef HANDLE
	_phGarmanKohlagenProcess = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppGarmanKohlagenProcess = new boost::shared_ptr<QuantLib::GarmanKohlagenProcess> (copy->GetShared());
        _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppGarmanKohlagenProcess));
    }
}
Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (System::Type^ t) : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
#ifdef HANDLE
	_phGarmanKohlagenProcess = NULL;
#endif
	if (!t->IsSubclassOf(CGarmanKohlagenProcess::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (QuantLib::Handle<QuantLib::GarmanKohlagenProcess>& childNative, Object^ owner)  : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
	_phGarmanKohlagenProcess = &childNative;
	_ppGarmanKohlagenProcess = &static_cast<boost::shared_ptr<QuantLib::GarmanKohlagenProcess>>(childNative.currentLink());
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppGarmanKohlagenProcess));
    _GarmanKohlagenProcessOwner = owner;
}
Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (QuantLib::Handle<QuantLib::GarmanKohlagenProcess> childNative)  : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
	_phGarmanKohlagenProcess = &childNative;
	_ppGarmanKohlagenProcess = &static_cast<boost::shared_ptr<QuantLib::GarmanKohlagenProcess>>(childNative.currentLink());
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppGarmanKohlagenProcess));
}
#endif
#ifdef STRUCT
Cephei::QL::Processes::CGarmanKohlagenProcess::CGarmanKohlagenProcess (QuantLib::GarmanKohlagenProcess childNative)  : CGeneralizedBlackScholesProcess(CGarmanKohlagenProcess::typeid)
{
#ifdef HANDLE
	_phGarmanKohlagenProcess = NULL;
#endif
	_ppGarmanKohlagenProcess = new boost::shared_ptr<QuantLib::GarmanKohlagenProcess> (new QuantLib::GarmanKohlagenProcess (childNative));
    _ppGeneralizedBlackScholesProcess = new boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppGarmanKohlagenProcess));
}
#endif

Cephei::QL::Processes::CGarmanKohlagenProcess::~CGarmanKohlagenProcess ()
{
    if (_ppGarmanKohlagenProcess != NULL)
    {
	    delete _ppGarmanKohlagenProcess;
        _ppGarmanKohlagenProcess = NULL;
    }
}
Cephei::QL::Processes::CGarmanKohlagenProcess::!CGarmanKohlagenProcess ()
{
    if (_ppGarmanKohlagenProcess != NULL)
    {
	    delete _ppGarmanKohlagenProcess;
    }
}
QuantLib::GarmanKohlagenProcess& Cephei::QL::Processes::CGarmanKohlagenProcess::GetReference ()
{
    if (_ppGarmanKohlagenProcess == NULL) throw gcnew NativeNullException ();
	return **_ppGarmanKohlagenProcess;
}
boost::shared_ptr<QuantLib::GarmanKohlagenProcess>& Cephei::QL::Processes::CGarmanKohlagenProcess::GetShared ()
{
    if (_ppGarmanKohlagenProcess == NULL) throw gcnew NativeNullException ();
	return *_ppGarmanKohlagenProcess;
}
QuantLib::GarmanKohlagenProcess* Cephei::QL::Processes::CGarmanKohlagenProcess::GetPointer ()
{
    if (_ppGarmanKohlagenProcess == NULL) throw gcnew NativeNullException ();
	return &**_ppGarmanKohlagenProcess;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::GarmanKohlagenProcess>& Cephei::QL::Processes::CGarmanKohlagenProcess::GetHandle ()
{
	if (_phGarmanKohlagenProcess == NULL)
	{
		_phGarmanKohlagenProcess = new Handle<QuantLib::GarmanKohlagenProcess> (*_ppGarmanKohlagenProcess);
	}
	return *_phGarmanKohlagenProcess;
}
#endif
bool Cephei::QL::Processes::CGarmanKohlagenProcess::HasNative () 
{
	return (_ppGarmanKohlagenProcess != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

